import os
from datetime import timedelta


class BaseConfig:
    SECRET_KEY = 'sd12GreAU56fgBNl'
    # 数据库相关
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 指定当视图执行完毕后,自动提交数据库操作
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True
    # 指定每次执行操作时打印原始的SQL语句
    SQLALCHEMY_ECHO = False
    # 数据页大小
    BLOG_PAGE_SIZE = 5  # 博客页大小
    STARLIST_PAGE_SIZE = 5  # 收藏列表分页
    EVENT_PAGE_SIZE = 5  # 活动分页
    PLACE_PAGE_SIZE = 5  # 景点分页
    USER_PER_PAGE = 5  # 用户分页大小

    # session保持时间是1天
    PERMANENT_SESSION_LIFETIME = timedelta(days=1)

    # 项目的绝对路径
    BASE_DIR = os.path.abspath(os.path.dirname(__file__))
    # 指定的图片上传路径
    IMAGE_ROOT = os.path.join(BASE_DIR, 'static', 'images')
    # 限制上传文件大小 10M
    MAX_CONTENT_LENGTH = 10 * 1024 * 1024

    JSON_AS_ASCII = False


# 开发环境配置
class DevelopmentConfig(BaseConfig):
    # 项目的域名地址
    BASE_SERVER = 'http://192.168.3.16:5000'
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://root:root@127.0.0.1:3306/mce?charset=utf8mb4"


# 测试环境配置
class ProductConfig(BaseConfig):
    DEBUG = False
    BASE_SERVER = 'https://menv.xyz:5000'
    SQLALCHEMY_DATABASE_URI = "mysql+pymysql://mce:ZjDYPeTNt4ytpycs@127.0.0.1:3306/mce?charset=utf8mb4"

